﻿using PidKeyReptile.Desktop.CrawlTask;
using PidKeyReptile.Desktop.Pages.Crawler;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PidKeyReptile.Desktop.QuartzTask
{
    public class JikeSyncJob : IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            var obj = context.JobDetail.JobDataMap["Crawler"];
            if (obj is CrawlerManagerViewModel crawler)
            {
                return Task.Run(async () =>
                {
                    crawler.LogText += ($"{DateTime.Now}--开始采集jike.info\r\n");
                    await new Jike_Info(crawler).CaptureAsync("https://jike.info/category/16/%E8%B4%A6%E5%8F%B7%E5%AF%86%E9%92%A5");
                });
            }
            else
            {
                return null;
            }
        }
    }
}
